package base.log4j;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;

public class TestLog {
	static Logger logger = Logger.getLogger(TestLog.class);

	public static void main(String[] args) {

		// get a logger instance named "com.foo"
		Logger logger = Logger.getLogger("base");
		logger.addAppender(new ConsoleAppender(new PatternLayout("%r [%t] %-5p %c - %m%n")));
		// Now set its level. Normally you do not need to set the
		// level of a logger programmatically. This is usually done
		// in configuration files.
		logger.setLevel(Level.INFO);


		logger.fatal(formatDate(new Date()));

		System.out.println("hello world");

	}

	public static String formatDate(Date date) {
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		String result = format.format(date);
		return result;
	}
}
